import { Injectable } from '@angular/core';
import {Observable} from 'rxjs';
import {HttpClient} from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class MqService {


  apiBase = "http://localhost:9000/gateway/user";

  constructor(private http: HttpClient) { }

  directSendMessage(msg:String){
    const url = this.apiBase + "/rabbitmq/demo/direct/sendMsg/" + msg;
    return this.http.get(url);
  }

  fauntSendMessage(msg:String){
    const url = this.apiBase + "/rabbitmq/demo/fanout/sendMsg/" + msg;
    return this.http.get(url);
  }

  serialSendMessage(msg:{}){
    const url = this.apiBase + "/rabbitmq/demo/serial/sendMsg";
    return this.http.post(url, msg);
  }

  confirmSend(msg:String){
    const url = this.apiBase + "/rabbitmq/demo/confirm/sendMsg/" + msg;
    return this.http.get(url);
  }

  returnSend(msg:String){
    const url = this.apiBase + "/rabbitmq/demo/return/sendMsg/" + msg;
    return this.http.get(url);
  }

  retrySend(msg:String){
    const url = this.apiBase + "/rabbitmq/demo/retry/sendMsg/" + msg;
    return this.http.get(url)
  }

  deadSend(msg:String){
    const url = this.apiBase + "/rabbitmq/demo/dead/sendMsg/" + msg;
    return this.http.get(url)
  }

}
